package com.xiu.travel.portal;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.xiu.travel.portal.notice.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.lang.reflect.Type;


@Service
@Slf4j
public class NoticeServiceImpl implements NoticeService {

    /**
     * 5.4 退票通知
     *
     * @param notice notice2
     * @return String
     */
    public String notice2(Notice2 notice) {
        log.info("notice:{}", notice);
        return "";
    }

    /**
     * 7.1 扣款通知
     *
     * @param notice notice3
     * @return String
     */
    public String notice3(Notice3 notice) {
        log.info("notice:{}", notice);
        return "";
    }

    /**
     * 7.2 退款通知
     *
     * @param notice notice4
     * @return String
     */
    public String notice4(Notice4 notice) {
        log.info("notice:{}", notice);
        return "";
    }

    /**
     * 8.1 航变通知
     *
     * @param notice Notice5
     * @return String
     */
    public String notice5(Notice5 notice) {
        log.info("notice:{}", notice);
        return "";
    }

    /**
     * 3.4 取消订单通知
     *
     * @param notice Notice6
     * @return String
     */
    public String notice6(Notice6 notice) {
        log.info("notice:{}", notice);
        return "";
    }

    /**
     * 7.3 申诉结果通知
     *
     * @param notice notice12
     * @return String
     */
    public String notice12(Notice12 notice) {
        log.info("notice:{}", notice);
        return "";
    }

    /**
     * 6.6 改期创单通知
     *
     * @param notice Notice8
     * @return String
     */
    public String notice8(Notice8 notice) {
        log.info("notice:{}", notice);
        return "";
    }

    /**
     * 5.5 退票拒回通知
     *
     * @param notice Notice7
     * @return String
     */
    public String notice9(Notice9 notice) {
        log.info("notice:{}", notice);
        return "";
    }

    /**
     * 3.6 已使用通知
     *
     * @param notice Notice10
     * @return String
     */
    public String notice10(Notice10 notice) {
        log.info("notice:{}", notice);
        return "";
    }

    /**
     * 3.5 占座通知
     *
     * @param notice Notice11
     * @return String
     */
    public String notice11(Notice11 notice) {
        log.info("notice:{}", notice);
        return "";
    }

    /**
     * 5.5 退票拒回通知
     *
     * @param notice Notice7
     * @return String
     */

    public String notice7(Notice7 notice) {
        log.info("notice:{}", notice);
        return "";
    }


    /**
     * 通知处理方法
     *
     * @param jsonObject JSONObject
     * @return String
     */
    @Override
    public String notice(JSONObject jsonObject) {
        log.info("jsonObject:{}", jsonObject);
        return switch (jsonObject.getInteger("noticeType")) {
            case 1 -> notice1(JSON.parseObject(String.valueOf(jsonObject), Notice1.class));
            case 2 -> notice2(JSON.parseObject(String.valueOf(jsonObject), Notice2.class));
            case 3 -> notice3(JSON.parseObject(String.valueOf(jsonObject), Notice3.class));
            case 4 -> notice4(JSON.parseObject(String.valueOf(jsonObject), Notice4.class));
            case 5 -> notice5(JSON.parseObject(String.valueOf(jsonObject), Notice5.class));
            case 6 -> notice6(JSON.parseObject(String.valueOf(jsonObject), Notice6.class));
            case 7 -> notice7(JSON.parseObject(String.valueOf(jsonObject), Notice7.class));
            case 8 -> notice8(JSON.parseObject(String.valueOf(jsonObject), Notice8.class));
            case 9 -> notice9(JSON.parseObject(String.valueOf(jsonObject), Notice9.class));
            case 10 -> notice10(JSON.parseObject(String.valueOf(jsonObject), Notice10.class));
            case 11 -> notice11(JSON.parseObject(String.valueOf(jsonObject), Notice11.class));
            case 12 -> notice12(JSON.parseObject(String.valueOf(jsonObject), Notice12.class));
            default -> "success";
        };
    }

    /**
     * 5.5 退票拒回通知
     *
     * @param notice Notice7
     * @return String
     */
    public String notice1(Notice1 notice) {
        log.info("notice:{}", notice);
        return "";
    }
}
